<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	
	$params=array('uniacid'=>$_SESSION['uniacid']);
    $fields=array('id','type','postsid','complaint_text','mid');
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_sns_complain',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$type=pdo_getcolumn('jy_sns_complaincate',array('id'=>$v['type']),'name');
		$info=pdo_get('core_members',array('id'=>$v['mid']),array('avatar','nickname'));
		
		$v['nickname']=$info['nickname'];
		$v['avatar']=$info['avatar'];
		$v['type']=$type?$type:'';
		$v['title']=pdo_getcolumn('jy_sns_post',array('id'=>$v['postsid']),'title');
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'投诉管理'),
			
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'nickname','title'=>'投诉人','type'=>'string'),
			array('name'=>'avatar','title'=>'头像','type'=>'image'),
			array('name'=>'title','title'=>'帖子标题','type'=>'string'),
			array('name'=>'type','title'=>'投诉类型','type'=>'string'),
			array('name'=>'complaint_text','title'=>'投诉内容','type'=>'string'),
			
			
			
		)),
	);
	//$return['status']=array('0'=>'隐藏','1'=>'显示');
	$return['htmls']=$htmls;
	exi($return);
	}

if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_sns_complain',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_sns_complain',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>